# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>

pkgname="intel-oneapi-dpcpp-cpp"
pkgver='2023.2.0'
# Figure out new _debpkgrel value using
# curl -L https://apt.repos.intel.com/oneapi/dists/all/main/binary-amd64/Packages | grep dpcpp-cpp
_debpkgrel='49495'
pkgrel=1
pkgdesc="Intel oneAPI DPC++/C++ Compiler"
arch=('loong64' 'x86_64')
url='https://software.intel.com/content/www/us/en/develop/tools/oneapi.html'
license=("custom")
source=("https://apt.repos.intel.com/oneapi/pool/main/${pkgname}-${pkgver}-${pkgver}-${_debpkgrel}_amd64.deb")
b2sums=('91b13b305a06fbc7bb1fdabef7477bb9a636f1fbe553e1f8dce76cb1c4456f6949d34d634de89c6d9635d99bba2f6aaaf33717c7c2b564884e26ac5b9662ee77')
noextract=(
    "${pkgname}-${pkgver}-${pkgver}-${_debpkgrel}_amd64.deb"
)
depends=('intel-oneapi-compiler-dpcpp-cpp-common' 'intel-oneapi-compiler-dpcpp-cpp-runtime'
         'intel-oneapi-compiler-shared-runtime' 'intel-oneapi-compiler-shared'
         'intel-oneapi-tbb' 'intel-oneapi-dev-utilities' 'intel-oneapi-common')
conflicts=('intel-oneapi-basekit')

package() {
    cd "${srcdir}"
    ar x "${srcdir}/${pkgname}-${pkgver}-${pkgver}-${_debpkgrel}_amd64.deb"
    tar xvf data.tar.xz -C "${pkgdir}"
    rm data.tar.xz

    # allow libs to be found
    local _lib_path='/opt/intel/oneapi/compiler'
    local _ldso_conf="${pkgdir}"/etc/ld.so.conf.d
    install -d "${_ldso_conf}"
    echo "${_lib_path}/latest/linux/lib" > "${_ldso_conf}/${pkgname}.conf"
    echo "${_lib_path}/latest/linux/lib/x64" >> "${_ldso_conf}/${pkgname}.conf"

    install -d "${pkgdir}"/usr/share/licenses/"${pkgname}"
    ln -s /usr/share/licenses/intel-oneapi "${pkgdir}"/usr/share/licenses/"${pkgname}"/oneapi
}
